<template>
  <!-- 我的好友 -->
  <page-loading :show="showPage">
  <view class="container myfriend-page">
    <view class="header">
      <view class="status-bar"></view>
      <view class="heads flex flex-ai-c flex-jc-sb">
        <view class="backs mr-20" @click="backclick">
          <u-icon name="arrow-left" color="#333" size="34rpx"></u-icon>
        </view>
        <view class="seachs">
          <u-search placeholder="请输入姓名或联系方式" :animation="true" v-model="keyword" height="60" @search="onSearch" @clear="onClear" @focus="showPopup = false"></u-search>
        </view>
        <view class="addbtn" @click="onClickAddFriend">
          <i-icon icon="icon-tainjia" type="single" size="46rpx" color="#3D3D3D"></i-icon>
        </view>
      </view>
    </view>
    
    <view class="bodys">
      
      <view class="notices flex flex-ai-c flex-jc-sb" @click="onClickDisabled">
        <view class="noticons">
          <i-icon icon="iconlipin-2" type="multiple" size="56rpx" class="iconpd"></i-icon>
        </view>
        <view class="nottext font-32 color-333">
          优惠活动通知
        </view>
        <view class="nitionstxt">
        </view>
      </view>
      <view class="notices flex flex-ai-c flex-jc-sb" @click="onClickDisabled">
        <view class="noticons1">
          <i-icon icon="iconyaoqing-2" type="multiple" size="56rpx" class="iconpd"></i-icon>
        </view>
        <view class="nottext font-32 color-333">
          7迈车收益日报
        </view>
        <view class="nitionstxt">
        </view>
      </view>
      <view class="notices flex flex-ai-c flex-jc-sb" @click="onJumpMass">
        <view class="noticons2">
          <i-icon icon="iconliaotian-2" type="multiple" size="56rpx" class="iconpd"></i-icon>
        </view>
        <view class="nottext font-32 color-333">
          群发助手
        </view>
        <view class="nitionstxt">
        </view>
      </view>
      
      <!-- 我的城市服务商 -->
      <view class="notices flex flex-ai-c flex-jc-sb" @click="onCheckBussInfo(res.serviceProvider)" v-if="res.serviceProvider">
        <view class="noticons2">
          <image :src="res.serviceProvider.headImg || defaultAvatar" mode="aspectFill"></image>
          <view class="iconred" v-if="res.serviceProvider.im && res.serviceProvider.im.unreadCount > 0"></view>
        </view>
        <view class="nottext font-32 color-333">
          {{res.serviceProvider.serviceName}}<br>
          <text class="font-24 color-999">我的城市服务商</text>
        </view>
        <view class="nitionstxt">
          <u-icon name="arrow-right" color="#9A9A9A" size="24rpx"></u-icon>
        </view>
      </view>
      
      <!-- 我的上级 -->
      <view class="notices flex flex-ai-c flex-jc-sb" v-if="res.parentUser" @click="onJumpChat(res.parentUser, 'C2C')">
        <view class="noticons2">
          <image :src="res.parentUser.headImg || defaultAvatar" mode="aspectFill" v-if="res.parentUser.uid < 0"></image>
          <image :src="res.parentUser.headImg" mode="aspectFill" v-else></image>
          <view class="iconred" v-if="res.parentUser.im && res.parentUser.im.unreadCount > 0"></view>
        </view>
        <view class="nottext font-32 color-333" style="width: 420rpx;">
          <view class="flex flex-ai-c">
            {{res.parentUser.userName}}
            <view class="1234" v-if="res.parentUser.isPartner">
              <image src="https://files.yzsheng.com/client/order/hehuorenicon.png" mode="aspectFill"></image><!-- 是合伙人 -->
            </view>
            <view class="1234" v-else>
              <image src="https://files.yzsheng.com/client/me/img/hehuoren2.png" mode="aspectFill"></image><!-- 不是合伙人 -->
            </view>
            <view class="1234" v-show="res.parentUser.isOwner">
              <image src="https://files.yzsheng.com/client/order/chebiao.png" mode="aspectFill"></image><!-- 车主 -->
            </view>
          </view>
          <text class="font-24 color-999">我的邀请人</text>
        </view>
        <view class="notbox font-24 color-666 flex flex-jc-c flex-ai-c" v-if="res.parentUser.shareCount > 0">
          已邀请<br>
          {{res.parentUser.shareCount}}人
        </view>
      </view>
      
      <!-- 群聊 -->
      <view>
        <view class="titles font-26 color-666 mb_15">
          群聊
        </view>
        <view class="notices flex flex-ai-c flex-jc-sb" v-for="(item, index) in myIMGroup" :key="index" @click="onJumpChat(item, 'GROUP')" v-if="myIMGroup && myIMGroup.length > 0">
          <view class="noticons2">
            <image :src="item.group_face_url" mode="aspectFill"></image>
            <view class="iconred" v-if="item.im && item.im.unreadCount > 0"></view>
          </view>
          <view class="nottext font-32 color-333" style="width:520rpx;">
            {{item.group_name}}<br>
            <text class="font-24 color-999">{{item | formatMessage}}</text>
          </view>
          <view class="nitionstxt color-999" v-if="item.im">
            {{item.im.lastMessage.lastTime | formatDate}}
          </view>
        </view>
        <view class="notices flex flex-ai-c flex-jc-sb" @click="onJumpChat(res.parentIMGroup, 'GROUP')" v-if="res.parentIMGroup">
          <view class="noticons2">
            <image :src="res.parentIMGroup.group_face_url" mode="aspectFill"></image>
            <view class="iconred" v-if="res.parentIMGroup.im && res.parentIMGroup.im.unreadCount > 0"></view>
          </view>
          <view class="nottext font-32 color-333" style="width:520rpx;">
            {{res.parentIMGroup.group_name}}<br>
            <text class="font-24 color-999">{{res.parentIMGroup | formatMessage}}</text>
          </view>
          <view class="nitionstxt color-999" v-if="res.parentIMGroup.im">
            {{res.parentIMGroup.im.lastMessage.lastTime | formatDate}}
          </view>
        </view>
      </view>
      
      <!-- 我的邀请 -->
      <view>
        <view class="titles font-26 color-666 mb_15">
          我邀请的
        </view>
        <view class="titlesqb mb_15 flex flex-jc-sb">
          <view :class="item.check? 'allnum' : 'allnumhs'" v-for="(item,index) in selectfriend" :key="index" @click="allnumClick(item,index)">
            {{item.name}}（{{item.number}}）
          </view>
        </view>
        
        <view style="height: 50vh;" v-if="result.isEnd && result.data.length <= 0">
          <u-empty mode="data" ></u-empty>
        </view>
        <firend-tree :list="result.data" v-else />
        
      </view>

    </view>
    
    <!-- 添加好友弹窗 -->
    <u-popup mode="top" v-model="showPopup">
      <view class="popup-content">
        <view class="cell-box">
          <view class="cell" @click="onChangeAddFriend('mobile')">
            <i-icon icon="iconshouji2" size="40rpx" color="#3d3d3d"></i-icon>
            <text class="text">手机联系人</text>
          </view>
          <view class="cell" @click="onChangeAddFriend('weixin')">
            <i-icon icon="iconweixin1" size="42rpx" color="#3d3d3d"></i-icon>
            <text class="text">微信</text>
          </view>
        </view>
      </view>
    </u-popup>
  </view>
  </page-loading>
</template>

<script src="./myFriend.js"></script>
<style src="./myFriend.scss" lang="scss" scoped></style>
